<?php

namespace plugins\member_login\validate;

use think\Validate;



/**

 * 

 */

class ApiValidate extends Validate

{

	protected $rule = [

		'name' => 'require',

		'pass' => 'require',

		'nick_name' => 'require',

		'phone' => 'require|regex:/^1[34578]\d{9}$/',

		'code' => 'require',

	];


	//返回的信息

	protected $message = [

		'name.require' => '账号不能为空',

		'pass.require' => '密码不能为空',

		// 'pass.min'	=>	'密码不能低于6位',

		// 'pass.max'	=>	'密码不能高于20位',

		'nick_name.require' => '昵称不能为空',

		'phone.require' => '手机号码不能为空',

		'phone.regex'	=>	'手机号码格式不正确',

		'code.require' => '验证码不能为空',

	];



	//检测方法需要的参数

	protected $scene = [
		'accountLogin' => [
			'name',
			'pass'
		],
		'wechatLogin' => [
			''
		],
		'phoneLogin' => [
			'phone',
			'code'
		],
		'accountRegiest' => [
			'name',
			'pass',
			'nick_name'
		],
		'phoneRegiest' => [

			'phone',

			'code',

			'nick_name'

		],

		'wechatRegiest'	=>	[

			''

		]

	];





	/**

	 * 自定义验证规则 -登录注册方式

	 */

	protected function checkWay( $value , $rule , $data )

	{

		return  in_array( $value , [ 'account' , 'phone' , 'wechat' ] ) ? true : '非法登录方式';

	}





	

}